/**
*create by Jancheng ON 2019/3/25
*
**/
<template>
    <div class="test">
        <qd-scroll :upOption="upOption" :downOption="downOption" top="40px">
            <div v-for="(item , key) in dataList" slot="data-list">
            {{item.title}}
            </div>
        </qd-scroll>
    </div>
</template>
<script>
    import qdScroll from '../../packages/qd-scroll/src/qd-scroll'
    export default {
        data:function(){
          let vm=this;
          return {
              dataList:[],
              dataTotal:[],
              upOption:{
                  callback:function (page, mescroll) {
                      vm.getDataList(page,mescroll);
                  },
                  // empty: {
                  //     warpId: null,
                  // },
              },
              downOption:{
                  callback:function (mescroll) {
                      vm.getDataList({num:0,size:50},mescroll,"DOWN");
                  }
              },
          }
        },
        mounted:function(){
          // this.getDataList();
        },
        methods:{
          getDataList:function (page,mescroll,type) {
              let vm=this;
              setTimeout(function () {
                  $.ajax({
                      url:'http://10.73.1.67:8100/app/mock/20/arrays',
                      success:function (data) {
                          if(page.num===0){
                              vm.dataList=[];
                          }
                          vm.dataList=vm.dataList.concat(data.data);
                          vm.dataTotal=data.total;
                          //
                          // vm.dataList= [];//vm.dataList.concat(data.data);
                          // vm.dataTotal=0;data.total;
                          setTimeout(function () {
                              vm.$nextTick(() => {
                                  if(vm.dataTotal==0){
                                      mescroll.endSuccess(0,0);
                                  }else{
                                      mescroll.endSuccess(data.data.length, vm.dataList.length<vm.dataTotal?true:false)
                                  }
                              })
                          },200)
                          console.info(vm.dataList)
                      }
                  })
              },1000)
          }
        },
        components:{
            qdScroll
        }
    }
</script>
<style lang="less">
</style>